#pragma once

#include"Common.h"

class BaseInfo
{
public:
	BaseInfo(const BaseLocation* baseLocation);
	void Initialize(const int& myBaseIndex , vector<BaseInfo>& allBases);
	void SetChokePoint(Chokepoint* chokePoint);
	const Position GetChokePointCenter() const;
	void OnFrame();

	bool LetMeJoin(Unit* worker);
	bool pleaseLetMeJoin(Unit* worker);
	void IamLeaving(Unit* worker);

	int GetBaseIndex();
	const BaseLocation* GetBaseLocation();
	vector<BaseInfo*> GetSortedOtherBases();
	double GetDistanceToBase(BaseInfo* anotherBaseInfo);

	Unit* GetHatchery();
	void SetHatchery(Unit* hatchery);
	bool HatcheryCantReturnResource() const;

	bool IsEnemyBase();

	bool operator<(const BaseInfo& another) const;
private:
	void Draw();
	//--
	const BaseLocation* _baseLocation;
	int _baseIndex;
	Player* _owner;

	Unit* _hatchery;
	vector<Unit*> _minerals;
	set<Unit*> _miningWorkers;
	vector<Unit*> _geysers;
	unordered_map<Unit* , set<Unit*>*> _geyserToWorkersTable;;

	Chokepoint* _myChokePoint;

	vector<BaseInfo*> _otherBasesTableByDistance;
	unordered_map<BaseInfo* , double> _allDistanceToOtherBases;
	double _distanceToMain;
};